import { useState } from "react";

function ChildOne({ onReceive }) {
  const [num, setNum] = useState(100);

  const sendNum = () => {
    setNum(num + 1);
    onReceive(num);
  };

  return (
    <div style={{ padding: "10px", backgroundColor: "#eee" }}>
      <h1>我是ChileOne组件</h1>
      <hr />
      <button onClick={() => sendNum()}>向父组件传递数据</button>
    </div>
  );
}

export default ChildOne;
